package com.baohua.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.baohua.dao.AutoCompleteDao;
import com.baohua.dao.BaseDao;
import com.baohua.model.Member;


@Repository("autoCompleteDao")
public class AutoCompleteDaoImpl extends BaseDao implements AutoCompleteDao {

	/**
	 * 获取所有member的编号
	 * 
	 * */
	@Override
	public List<String> getAllMemberNo() {
		String sql = "select memberNo from Member";
		Query query = this.getSession().createQuery(sql);
		@SuppressWarnings("unchecked")
		List<String> list = query.list();
		return list;
	}

	/**
	 * 获取所有member的姓名
	 * 
	 * */
	@Override
	public List<String> getAllMemberName() {
		String sql = "select memberName from Member";
		Query query = this.getSession().createQuery(sql);
		@SuppressWarnings("unchecked")
		List<String> list = query.list();
		return list;
	}
	
	/**
	 * 获取所有member的电话
	 * 
	 * */
	@Override
	public List<String> getAllMobile() {
		String sql = "select mobile from Member";
		Query query = this.getSession().createQuery(sql);
		@SuppressWarnings("unchecked")
		List<String> list = query.list();
		return list;
	}

	@Override
	public Member getMemberByMemberNo(String memberNo) {
		String sql = "from Member m where m.Member=?";
		Member member = (Member) this.getSession().createQuery(sql).setString(0, memberNo).uniqueResult();		
		return member;
	}
}
